/*
* Sun Public License Notice
*
* The contents of this file are subject to the Sun Public License
* Version 1.0 (the "License"). You may not use this file except in
* compliance with the License. A copy of the License is available at
* http://www.sun.com/
*
* The Original Code is Forte for Java, Community Edition. The Initial
* Developer of the Original Code is Sun Microsystems, Inc. Portions
* Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
*/
package org.netbeans.modules.javadoc.comments;
import org.openide.src.MemberElement;
import org.openide.src.ConstructorElement;
import org.openide.src.FieldElement;
import org.openide.src.ClassElement;
import org.openide.src.JavaDocTag;
import org.openide.src.JavaDocSupport;
/**
*
* @author
* @version
*/
public class StandardTagPanel extends TagPanel implements JavaTagNames {
private static final String cardName = "CRD_STANDARD"; // NOI18N
private static final String[] classTags = {
TAG_AUTHOR,
TAG_DEPRECATED,
TAG_SINCE,
TAG_VERSION };
private static final String[] fieldTags = {
TAG_DEPRECATED,
TAG_SERIAL,
TAG_SINCE };
private static final String[] methodTags = {
TAG_DEPRECATED,
TAG_RETURN,
TAG_SERIALDATA,
TAG_SINCE };
static final long serialVersionUID =134652804415020896L;
/** Initializes the Form */
public StandardTagPanel( MemberElement element, JavaDocEditorPanel editorPanel ) {
super( editorPanel );
initComponents ( );
if ( element instanceof ConstructorElement ) {
for( int i = 0; i < methodTags.length; i++ ) {
nameComboBox.addItem( methodTags[i] );
}
nameComboBox.setSelectedItem( "" ); // NOI18N
}
else if ( element instanceof FieldElement ) {
for( int i = 0; i < fieldTags.length; i++ ) {
nameComboBox.addItem( fieldTags[i] );
}
nameComboBox.setSelectedItem( "" ); // NOI18N
}
if ( element instanceof ClassElement ) {
for( int i = 0; i < classTags.length; i++ ) {
nameComboBox.addItem( classTags[i] );
}
nameComboBox.setSelectedItem( "" ); // NOI18N
}
addHTMLComponent( descriptionTextArea );
editorPanel.registerComponent( descriptionTextArea );
nameComboBox.getEditor().getEditorComponent().addFocusListener(
new java.awt.event.FocusAdapter () {
public void focusLost (java.awt.event.FocusEvent evt) {
commitTagChange();
}
});
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the FormEditor.
*/
private void initComponents () {//GEN-BEGIN:initComponents
setLayout (new java.awt.GridBagLayout ());
java.awt.GridBagConstraints gridBagConstraints1;
jLabel2 = new javax.swing.JLabel ();
jLabel2.setText (org.openide.util.NbBundle.getBundle(StandardTagPanel.class).getString("CTL_StandardTagPanel.jLabel2.text"));
jLabel2.setHorizontalAlignment (javax.swing.SwingConstants.LEFT);
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.insets = new java.awt.Insets (2, 2, 2, 1);
gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
add (jLabel2, gridBagConstraints1);
nameComboBox = new javax.swing.JComboBox ();
nameComboBox.setMaximumRowCount (4);
nameComboBox.setEditable (true);
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.insets = new java.awt.Insets (2, 1, 2, 2);
gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
add (nameComboBox, gridBagConstraints1);
jLabel1 = new javax.swing.JLabel ();
jLabel1.setText (org.openide.util.NbBundle.getBundle(StandardTagPanel.class).getString("CTL_StandardTagPanel.jLabel1.text"));
jLabel1.setHorizontalAlignment (javax.swing.SwingConstants.LEFT);
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.insets = new java.awt.Insets (2, 2, 2, 1);
gridBagConstraints1.anchor = java.awt.GridBagConstraints.NORTHWEST;
add (jLabel1, gridBagConstraints1);
descriptionScrollPane = new javax.swing.JScrollPane ();
descriptionTextArea = new javax.swing.JEditorPane ();
descriptionTextArea.setContentType ("text/html"); // NOI18N
descriptionTextArea.addFocusListener (new java.awt.event.FocusAdapter () {
public void focusGained (java.awt.event.FocusEvent evt) {
descriptionTextAreaFocusGained (evt);
}
public void focusLost (java.awt.event.FocusEvent evt) {
descriptionTextAreaFocusLost (evt);
}
}
);
descriptionScrollPane.setViewportView (descriptionTextArea);
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.gridheight = 0;
gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints1.insets = new java.awt.Insets (2, 1, 2, 2);
gridBagConstraints1.weightx = 1.0;
gridBagConstraints1.weighty = 1.0;
add (descriptionScrollPane, gridBagConstraints1);
}//GEN-END:initComponents
private void descriptionTextAreaFocusGained (java.awt.event.FocusEvent evt) {//GEN-FIRST:event_descriptionTextAreaFocusGained
enableHTMLButtons( true );
}//GEN-LAST:event_descriptionTextAreaFocusGained
private void descriptionTextAreaFocusLost (java.awt.event.FocusEvent evt) {//GEN-FIRST:event_descriptionTextAreaFocusLost
enableHTMLButtons( false );
commitTagChange();
}//GEN-LAST:event_descriptionTextAreaFocusLost
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel jLabel2;
private javax.swing.JComboBox nameComboBox;
private javax.swing.JLabel jLabel1;
private javax.swing.JScrollPane descriptionScrollPane;
private javax.swing.JEditorPane descriptionTextArea;
// End of variables declaration//GEN-END:variables
void setData( JavaDocTag tag ) {
nameComboBox.getEditor().setItem( tag.name() );
descriptionTextArea.setText( tag.text() );
descriptionTextArea.setCaretPosition( 0 );
}
JavaDocTag getTag( String tagName ) {
return JavaDocSupport.createTag( (String) nameComboBox.getEditor().getItem(),
descriptionTextArea.getText() );
};
String getCardName() {
return cardName;
}
void grabFirstFocus() {
nameComboBox.grabFocus();
}
}
/*
* Log
* 9 Gandalf 1.8 1/12/00 Petr Hrebejk i18n
* 8 Gandalf 1.7 1/3/00 Petr Hrebejk Bugfix 4972
* 7 Gandalf 1.6 1/3/00 Petr Hrebejk Various bugfixes - 4709,
* 4978, 5017, 4981, 4976, 5016, 4740, 5005
* 6 Gandalf 1.5 11/27/99 Patrik Knakal
* 5 Gandalf 1.4 11/10/99 Petr Hrebejk Workaround for catching
* the mnemonics of HTML tag buttons
* 4 Gandalf 1.3 10/23/99 Ian Formanek NO SEMANTIC CHANGE - Sun
* Microsystems Copyright in File Comment
* 3 Gandalf 1.2 9/16/99 Petr Hrebejk Tag descriptions editing
* in HTML editor + localization
* 2 Gandalf 1.1 8/13/99 Petr Hrebejk Window serialization
* added & Tag change button in Jdoc editor removed
* 1 Gandalf 1.0 7/9/99 Petr Hrebejk
* $
*/